<template>
	<el-container>

        <div style="width: 99%;margin-left:9px;margin-top: 10px;">
                <el-card style="width:100%">
						<el-form :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="100px" label-position="right">

						    <el-form-item label="是否开启" prop="ex_jifen">
								<el-switch v-model="form.status" active-value="1" inactive-value="0"></el-switch>
							</el-form-item>
						    <el-form-item label="奖励类型" prop="share_type">
								   <el-radio-group v-model="form.share_type">
								     <el-radio :label="1">邀请新用户注册会员获得</el-radio>
								     <el-radio :label="2">邀请新用户首次下单获得</el-radio>
									 <el-radio :label="3">邀请新用户首次充值获得</el-radio>
								   </el-radio-group>
							</el-form-item>
						    <el-form-item label="分享获得礼品" prop="profit">
									<el-checkbox-group v-model="form.profit">
											<div class="chkbox">
												<el-checkbox label="jifen" class="chk2">获得积分</el-checkbox>
												<el-input placeholder="输入积分" class="chkbox_ipt" v-model="form.jifen"></el-input>
											</div>
											<div class="chkbox">
											    <el-checkbox label="money" class="chk2">获得余额奖励</el-checkbox>
												<el-input placeholder="输入金额" class="chkbox_ipt" v-model="form.money"></el-input>
											</div>
											<div class="chkbox">
											     <el-checkbox label="coupon" class="chk2">获得优惠券</el-checkbox>
												 <el-select class="chkbox_se" v-model="form.coupon" filterable>
														<el-option
															  v-for="item in coupon"
															  :key="item.id"
															  :label="item.title"
															  :value="item.id">
														</el-option>
												 </el-select>
											</div>
											<div class="chkbox">
											      <el-checkbox label="miandan" class="chk2">一次免单机会</el-checkbox>
												  <div class="el-form-item-msg" data-v-b33b3cf8="">订单中最低价格的商品免费</div>
											</div>
											<div class="chkbox">
											      <el-checkbox label="banjia" class="chk2">一次半价机会</el-checkbox>
												  <div class="el-form-item-msg" data-v-b33b3cf8="">订单中最低价格的商品半价</div>
											</div>
									</el-checkbox-group>
							</el-form-item>
							<el-form-item label=" " prop="ex_jifen">
								<el-button type="primary" @click='subForm'>保 存</el-button>
							</el-form-item>


						</el-form>
                </el-card>
        </div>

	</el-container>
</template>

<script>
	export default {
		name: 'mk_share',
		data() {
			return {
				form:{},
				coupon:[]
			}
		},
		mounted() {
			 this.getShare()
			 this.getcoupon()
		},
		methods: {
			async getShare(){
				var res = await this.$API.system.universal.list.get({},'/mk/share');
				if(res.code == 200){
					 this.form = res.data
				}
			},
			async getcoupon(){
				var res = await this.$API.system.universal.list.get({'nopage':1},'/mk/coupon');
				if(res.code == 200){
					 this.coupon = res.data
				}
			},
			async subForm(){
				var res = await this.$API.system.universal.handle.post(this.form,'/mk/share_save');
				this.isSaveing = false;
				if(res.code == 200){
					this.$emit('success', this.form, this.mode)
					this.visible = false;
					this.$message.success("操作成功")
				}else{
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}

		}
	}
</script>

<style>
.chkbox{
	width:100%;
	margin-bottom: 15px;
}
.chk2{

}
.chkbox_ipt{
	width: 120px;
	margin-left: 10px;
}
.chkbox_se{
	width: 220px;
	margin-left: 10px;
}
.red{
    font-size: 15px;
    color:#ff3333
}
.feng{
    width: 40px;
    height: 40px;
    border-radius: 100%;
}
</style>

